<?php

namespace Drupal\shusy_point_product\ViewsController;

use Drupal\shusy_point_product\ViewsController\handler\field\ShusyPointProductEditLinkViewsField;
use Drupal\shusy_point_product\ViewsController\handler\field\ShusyPointProductStatusViewsField;
use Drupal\shusy_point_product\ViewsController\handler\field\ShusyPointProductUnitViewsField;
use Drupal\shusy_point_product\ViewsController\handler\filter\ShusyPointProductStatusViewsFilter;
use Drupal\shusy_point_product\ViewsController\handler\filter\ShusyPointProductUnitViewsFilter;
use EntityDefaultViewsController;


class ShusyPointProductViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => ShusyPointProductEditLinkViewsField::class,
        ],
      ];
      $info[$table]['unit'] = [
        'title' => '单位 0 克 1 千克',
        'help' => '单位 0 克 1 千克',
        'real field' => 'unit',
        'field' => [
          'handler' => ShusyPointProductUnitViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyPointProductUnitViewsFilter::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 下架 1 上架',
        'help' => '状态 0 下架 1 上架',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyPointProductStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyPointProductStatusViewsFilter::class,
        ],
      ];
      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
